/* PSS header */

#ifndef ALG_PSS_HEADER
#define ALG_PSS_HEADER

#ifdef __cplusplus
extern "C" {
#endif

#include "prefix_tree.h"
typedef evnode * cluster_el;

/* Define list of clusters                                               */
/* --------------------------------------------------------------------- */
DLNODE(cluster_n, cluster_el);
DLLIST(cluster_l, cluster_n);

GEN_DLINKEDLIST_FUNCTIONS_DECLARATION(dll_cluster, cluster_l, cluster_n, cluster_el);
/* --------------------------------------------------------------------- */

/* Define list of ntrienodes                                             */
/* --------------------------------------------------------------------- */
DLNODE(setnt_n, ntrieNode *);
DLLIST(setnt_l, setnt_n);

GEN_DLINKEDLIST_FUNCTIONS_DECLARATION(dll_setnt, setnt_l, setnt_n, ntrieNode *);
/* --------------------------------------------------------------------- */

void pss(psa *trie);

static int cmp_evnode(const void *p1, const void *p2);
static void split(evnode **orderedNodes, unsigned int on_size, cluster_l ***aln, unsigned int *n_subset);
static void select_non_removed_nodes(psa *trie, evnode ***out_array, unsigned int *size);
static void similarity(psa *trie, cluster_l **array_cluster_list, unsigned int size, int *eq_nodes);

static void K_S_test(double *clkarray1, unsigned int clk1_size, double *clkarray2, unsigned int clk2_size, double alpha, double *h, double *p, double *k);
static void merge(heap_mg *heap, evnode *x1, evnode *x2, unsigned int rec, ntrie *tail);


#ifdef __cplusplus
}
#endif

#endif
